package com.huawei.appmarket.service.settings.view.fragment;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.huawei.appgallery.foundation.ui.framework.cardframe.fragment.TaskFragment;
import com.huawei.appmarket.service.usercenter.userinfo.view.activity.InfoChangeActivity;
import com.huawei.updatesdk.service.otaupdate.UpdateStatusCode.DialogButton;
import huawei.widget.HwButton;
import java.util.List;
import o.azb;
import o.cjo;
import o.cvt;
import o.der.d;
import o.der.f;
import o.der.g;
import o.dgm;
import o.djl;
import o.Logger;
import o.dof;
import o.ely;
import o.emj;
import o.evk;

public class SettingReceivePrizeFragment extends TaskFragment<cjo> implements OnClickListener {
    private HwButton ʼ;
    private djl ʽ;
    private String ˊ = null;
    private boolean ˋ = true;
    private boolean ˎ = false;
    private TextView ˏ = null;
    private String ॱ = "";
    private TextView ॱॱ = null;

    public static SettingReceivePrizeFragment ˏ(boolean z, String str, String str2, boolean z2) {
        SettingReceivePrizeFragment settingReceivePrizeFragment = new SettingReceivePrizeFragment();
        settingReceivePrizeFragment.ॱ(z, str, str2, z2);
        return settingReceivePrizeFragment;
    }

    private void ॱ(boolean z, String str, String str2, boolean z2) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("has_addrss", z);
        bundle.putString("phone", str);
        bundle.putString("country_phone_code", str2);
        bundle.putBoolean("is_china_area", z2);
        ʼ(bundle);
    }

    public void ˏ(Bundle bundle) {
        ॱˋ(true);
        Bundle ˊॱ = ˊॱ();
        if (ˊॱ != null) {
            this.ˊ = ˊॱ.getString("phone");
            this.ॱ = ˊॱ.getString("country_phone_code");
            this.ˎ = ˊॱ.getBoolean("has_addrss");
            this.ˋ = ˊॱ.getBoolean("is_china_area");
        }
        super.ˏ(bundle);
    }

    public View ˋ(@NonNull LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        if (ॱˋ() != null) {
            ॱˋ().setTitle(ॱ(f.ˋˉ));
        }
        View inflate = layoutInflater.inflate(g.ˋˋ, viewGroup, false);
        this.ˏ = (TextView) inflate.findViewById(d.ꜟॱ);
        this.ॱॱ = (TextView) inflate.findViewById(d.ॱ);
        this.ˏ.setOnClickListener(this);
        inflate.findViewById(d.ॱﾟ).setOnClickListener(this);
        inflate.findViewById(d.ᐝʻ).setOnClickListener(this);
        azb.ˏ(inflate, d.ॱﾟ);
        azb.ˏ(inflate, d.ᐝʻ);
        this.ʼ = (HwButton) inflate.findViewById(d.ㆍ);
        this.ʼ.setOnClickListener(this);
        azb.ˎ(inflate, d.ˊʻ);
        ॱ();
        ʽˊ();
        return inflate;
    }

    private void ॱ() {
        if (dof.ˋ(this.ˊ)) {
            this.ˏ.setText(ॱ(f.ʳ));
        } else {
            CharSequence ॱ;
            TextView textView = this.ˏ;
            if (this.ˋ) {
                ॱ = ॱ(this.ˊ);
            } else {
                ॱ = '+' + this.ॱ + '-' + emj.ˏ(this.ˊ);
            }
            textView.setText(ॱ);
        }
        if (this.ˎ) {
            this.ॱॱ.setText(ॱ(f.ʻॱ));
        } else {
            this.ॱॱ.setText(ॱ(f.ʳ));
        }
    }

    private String ॱ(String str) {
        return emj.ˊ(str);
    }

    private void ʽˊ() {
        if (!dof.ˋ(this.ˊ) || this.ˎ) {
            this.ʼ.setEnabled(true);
        } else {
            this.ʼ.setEnabled(false);
        }
    }

    public void onClick(View view) {
        if (ॱˋ() != null && !ॱˋ().isFinishing() && !ॱˋ().isDestroyed()) {
            Intent intent;
            Bundle bundle;
            if (view.getId() == d.ॱﾟ || view.getId() == d.ꜟॱ) {
                intent = new Intent();
                bundle = new Bundle();
                bundle.putInt("changeKind", 1);
                bundle.putBoolean("is_china_area", this.ˋ);
                intent.putExtras(bundle);
                intent.setClass(ॱˋ(), InfoChangeActivity.class);
                try {
                    ˋ(intent, 100);
                } catch (ActivityNotFoundException e) {
                    Logger.ˋ("SettingReceivePrizeFragment", "ActivityNotFoundException :" + e.toString());
                }
            } else if (view.getId() == d.ᐝʻ) {
                intent = new Intent();
                bundle = new Bundle();
                bundle.putInt("changeKind", 2);
                bundle.putBoolean("is_china_area", this.ˋ);
                intent.putExtras(bundle);
                intent.setClass(ॱˋ(), InfoChangeActivity.class);
                try {
                    ˋ(intent, DialogButton.CONFIRM);
                } catch (ActivityNotFoundException e2) {
                    Logger.ˋ("SettingReceivePrizeFragment", "ActivityNotFoundException :" + e2.toString());
                }
            } else if (view.getId() == d.ㆍ) {
                if (this.ʽ == null) {
                    this.ʽ = new djl(ॱˋ());
                    this.ʽ.ˋ(ॱ(f.ˏͺ));
                }
                this.ʽ.show();
                ʿˊ();
            }
        }
    }

    public void ˋ(TaskFragment taskFragment, List<cvt> list) {
        ely ˊ = ely.ˊ();
        ˊ.setServiceType_(dgm.ˎ(ॱˋ()));
        list.add(ˊ);
    }

    public boolean ˊ(TaskFragment taskFragment, b bVar) {
        Activity ॱˋ = ॱˋ();
        if (!(ॱˋ == null || ॱˋ.isFinishing() || ॱˋ.isDestroyed())) {
            ʼᐝ();
            if (bVar == null || bVar.ˋ == null || bVar.ˋ.getRtnCode_() != 0) {
                Logger.ˏ("SettingReceivePrizeFragment", "OnCompleted clear prize info fail");
                evk.ˏ(ॱˋ(), f.ͺˎ, 0).ˋ();
            } else {
                Logger.ˏ("SettingReceivePrizeFragment", "OnCompleted clear prize info success");
                evk.ˏ(ॱˋ(), f.ᐨॱ, 0).ˋ();
                this.ˊ = null;
                this.ˎ = false;
                ॱ();
                ʽˊ();
            }
        }
        return false;
    }

    private void ʼᐝ() {
        if (this.ʽ != null) {
            this.ʽ.dismiss();
        }
    }

    public void ॱ(int i, int i2, Intent intent) {
        super.ॱ(i, i2, intent);
        if (i2 == -1 && intent != null) {
            if (100 == i) {
                String stringExtra = intent.getStringExtra("phone");
                String stringExtra2 = intent.getStringExtra("country_phone_code");
                if (!dof.ˋ(stringExtra)) {
                    this.ˊ = stringExtra;
                }
                if (!dof.ˋ(stringExtra2)) {
                    this.ॱ = stringExtra2;
                }
                ॱ();
                ʽˊ();
            } else if (DialogButton.CONFIRM == i) {
                this.ˎ = intent.getBooleanExtra("has_addrss", this.ˎ);
                ॱ();
                ʽˊ();
            }
        }
    }
}
